/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hw2;

/**
 *
 * @author Avishay
 */
public class Rectangle {

    private Point start;
    private Point end;

    public Rectangle(Point start, Point end) {
        this.start = start;
        this.end = end;
    }

    public Rectangle(int sx, int sy, int ex, int ey) {
        this.start = new Point(sx, sy);
        this.end = new Point(ex, ey);
    }
    
    public Point getStartPoint() {
        return this.start;
    }
    
    public Point getEndPoint() {
        return this.end;
    }
    
    public boolean isClashingWith(Rectangle other) {
        boolean is_clashing = false;
        
        Point b_point = new Point(this.end.getX(), this.start.getY());
        Point c_point = new Point(this.start.getX(), this.end.getY());
        
        if (this.start.inRectangle(other)) {
            is_clashing = true;
        }
        else if (this.end.inRectangle(other)) {
            is_clashing = true;
        }
        else if (b_point.inRectangle(other)) {
            is_clashing = true;
        }
        else if (c_point.inRectangle(other)) {
            is_clashing = true;
        }

        return is_clashing;
    }
}
